package org.come.xinyuan;

import com.tool.role.RoleData;
import come.tool.JDialog.TiShiChuLi;
import org.come.Jpanel.TestPetJpanel;
import org.come.mouslisten.PetAddPointMouslisten;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.FormsManagement;
import org.come.until.UserMessUntil;

import java.math.BigDecimal;

public class ChengShengJDialog implements TiShiChuLi {
    public ChengShengJDialog() {
    }

    @Override
    public void tipBox(boolean tishi, Object object) {
        if (tishi) {
            String sendmes = Agreement.getAgreement().XinYuanAgreement("C&" + object);
            SendMessageUntil.toServer(sendmes);
            int exi = -1;
            for (int i = 0; i < UserMessUntil.getPetListTable().size(); i++) {
                if (UserMessUntil.getPetListTable().get(i).getSid().compareTo(new BigDecimal(object + "")) == 0) {
                    exi = i;
                }
            }
            UserMessUntil.getPetListTable().remove(exi);
            TestPetJpanel.showListModel(UserMessUntil.getPetListTable(), RoleData.getRoleData().getLoginResult().getSummoning_id());
            FormsManagement.HideForm(19);
            FormsManagement.HideForm(688);
            // 判断是否还有召唤兽
            if (UserMessUntil.getPetListTable().size() <= 0) {// 没有
                TestPetJpanel.getLabname().setText("");
                TestPetJpanel.getLabHP().setText("");
                TestPetJpanel.getLabMP().setText("");
                TestPetJpanel.getLabAP().setText("");
                TestPetJpanel.getLabSP().setText("");
                TestPetJpanel.getLabEXP().setText("");
                TestPetJpanel.getLabpower().setText("");
                TestPetJpanel.getLabspeed().setText("");
                TestPetJpanel.getLabpointnumber().setText("");
                TestPetJpanel.getLabrootbone().setText("");
                TestPetJpanel.getLabintelligence().setText("");
                TestPetJpanel.getLablevel().setText("");
                TestPetJpanel.getLabloyalty().setText("");
                UserMessUntil.setChosePetMes(null);
            } else {
                // 判断是否有参战的召唤兽
                if (RoleData.getRoleData().getLoginResult().getSummoning_id() != null) {
                    int exi2 = 0;
                    for (int i = 0; i < UserMessUntil.getPetListTable().size(); i++) {
                        if (RoleData.getRoleData().getLoginResult().getSummoning_id()
                                .compareTo(UserMessUntil.getPetListTable().get(i).getSid()) == 0) {
                            exi2 = i;
                        }
                    }
                    // 展示参战的召唤兽信息
                    UserMessUntil.setChosePetMes(UserMessUntil.getPetListTable().get(exi2));
                    PetAddPointMouslisten.showPetValue();
                } else {
                    // 展示第一只召唤兽的信息
                    UserMessUntil.setChosePetMes(UserMessUntil.getPetListTable().get(0));
                    PetAddPointMouslisten.showPetValue();
                }
            }
            // 关闭召唤兽技能面板
            FormsManagement.HideForm(18);
        }

    }

}